Skip to content

Ruby: Fix native extension loading for new RubyGems (Ruby 4.1+)#1281

Merged
marcoroth merged 1 commit intomainfrom
require-native-extension
Mar 3, 2026
Merged

Ruby: Fix native extension loading for new RubyGems (Ruby 4.1+)#1281
marcoroth merged 1 commit intomainfrom
require-native-extension

Conversation

@marcoroth
Copy link
Owner

This pull request changes the native extension loading from require_relative to require to ensure compatibility with the latest RubyGems, which no longer installs native extensions into the gem's lib/ directory by default. See ruby/rubygems#9240.

Using require resolves the extension through $LOAD_PATH, which RubyGems populates with both the lib/ and extension directories, so this works on both old and new versions of RubyGems.

Resolves #1244

@marcoroth
Copy link
Owner Author

@composerinteralia does this look right to you?

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 3, 2026

npx https://pkg.pr.new/@herb-tools/formatter@1281
npx https://pkg.pr.new/@herb-tools/language-server@1281
npx https://pkg.pr.new/@herb-tools/linter@1281

commit: 12bffbf

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit 12bffbf


✅ Preview deployment has been cleaned up.

Copy link
Contributor

@composerinteralia composerinteralia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is what some other gems have done as well 👍🏻. Sorry, I meant to open a PR with this but I forgot.

@marcoroth
Copy link
Owner Author

Awesome, thanks for the quick reply! 🙏🏼

@marcoroth marcoroth merged commit e3c2423 into main Mar 3, 2026
32 checks passed
@marcoroth marcoroth deleted the require-native-extension branch March 3, 2026 12:49
marcoroth added a commit that referenced this pull request Mar 4, 2026
Sadly the require change in #1281 is now causing the `require "herb"` locally to favor the locally installed herb gem over the local herb version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using require_relative for the extension is not compatible with latest rubygems

2 participants